gtkpixelcache: Fix possibly ignoring queued redraw
authorOlivier Brunel <jjk@jjacky.com>
Tue, 5 Nov 2013 18:21:28 +0000 (19:21 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 12 Nov 2013 04:17:14 +0000 (23:17 -0500)
If a queue_redraw() (invalidating a region, or the whole widget) was
called from the draw() call, it could get ignored if surface_dirty
existed, as it would then be updated, but destroyed right at the end of
the _gtk_pixel_cache_repaint(), leading the next call to
_gtk_pixel_cache_draw() have its call to repaint() be a no-op
(since there's no surface_dirty) and then simply draw from (non
updated) surface.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
https://bugzilla.gnome.org/show_bug.cgi?id=711545

gtk/gtkpixelcache.c

index 2c033305571f49f7917215e2286261d10a4f6056..411a75e7c324ce16ad2d3c2fa8bee6e872ce508d 100644 (file)
@@ -327,13 +327,15 @@ _gtk_pixel_cache_repaint (GtkPixelCache *cache,
                          gpointer user_data)
 {
   cairo_t *backing_cr;
+  cairo_region_t *region_dirty = cache->surface_dirty;
+  cache->surface_dirty = NULL;
 
   if (cache->surface &&
-      cache->surface_dirty &&
-      !cairo_region_is_empty (cache->surface_dirty))
+      region_dirty &&
+      !cairo_region_is_empty (region_dirty))
     {
       backing_cr = cairo_create (cache->surface);
-      gdk_cairo_region (backing_cr, cache->surface_dirty);
+      gdk_cairo_region (backing_cr, region_dirty);
       cairo_clip (backing_cr);
       cairo_translate (backing_cr,
                       -cache->surface_x - canvas_rect->x - view_rect->x,
@@ -370,11 +372,8 @@ _gtk_pixel_cache_repaint (GtkPixelCache *cache,
       cairo_destroy (backing_cr);
     }
 
-  if (cache->surface_dirty)
-    {
-      cairo_region_destroy (cache->surface_dirty);
-      cache->surface_dirty = NULL;
-    }
+  if (region_dirty)
+    cairo_region_destroy (region_dirty);
 }
 
 static gboolean